package part4createthread;

/**
 * @description: 测试守护线程
 * @author: zhang hang
 * @date: 2022/10/6 14:30.
 * @version: 1.0
 */
public class DaemonThread01 {
    public static void main(String[] args) {
        Thread thread = new Thread(new God());
        thread.setDaemon(true);
        thread.start();

        new Thread(new Person()).start();
    }
}

class God implements Runnable {

    @Override
    public void run() {
        while (true) {
            System.out.println("阿弥陀佛耶稣保佑你");
        }
    }
}

class Person implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println("这是我活的第" + (i + 1) + "年");
        }
        System.out.println("Bye, dude");
    }
}